﻿namespace WMS6.Web
{
    using System;
    using System.Collections.Generic;
    using System.Data;
    using System.Web;
    using WMS6.Web.InboundServiceRef;

    public class InboundServiceClientProxy : BasePage
    {
        public string BatchExecutePalletizing(List<string> receiptID)
        {
            PubParasInfo pubParasInfo = this.InitPubParasInfo();
            using (InboundServiceClient client = new InboundServiceClient("WSHttpBinding_IInboundService"))
            {
                return client.BatchExecutePalletizing(receiptID, pubParasInfo);
            }
        }

        public string BatchRevertPalletizing(List<string> receiptID)
        {
            PubParasInfo pubParasInfo = this.InitPubParasInfo();
            using (InboundServiceClient client = new InboundServiceClient("WSHttpBinding_IInboundService"))
            {
                return client.BatchRevertPalletizing(receiptID, pubParasInfo);
            }
        }

        public string CancelPalletizing(string receiptID)
        {
            PubParasInfo pubParasInfo = this.InitPubParasInfo();
            using (InboundServiceClient client = new InboundServiceClient("WSHttpBinding_IInboundService"))
            {
                return client.RevertPalletizing(receiptID, pubParasInfo);
            }
        }

        public string CheckPoIsGeneratedASN(string PoID)
        {
            PubParasInfo pubParasInfo = this.InitPubParasInfo();
            using (InboundServiceClient client = new InboundServiceClient("WSHttpBinding_IInboundService"))
            {
                return client.CheckPoIsGeneratedASN(PoID, pubParasInfo);
            }
        }

        public string CloseReceipt(List<string> receiptIDs)
        {
            PubParasInfo pubParasInfo = this.InitPubParasInfo();
            using (InboundServiceClient client = new InboundServiceClient("WSHttpBinding_IInboundService"))
            {
                return client.CloseReceipt(receiptIDs, pubParasInfo);
            }
        }

        public string DeleteReceiptInfo(List<string> receiptIDS)
        {
            PubParasInfo pubParasInfo = this.InitPubParasInfo();
            using (InboundServiceClient client = new InboundServiceClient("WSHttpBinding_IInboundService"))
            {
                return client.DeleteReceiptInfo(receiptIDS, pubParasInfo);
            }
        }

        public string ExecutePalletizing(string receiptID)
        {
            PubParasInfo pubParasInfo = this.InitPubParasInfo();
            using (InboundServiceClient client = new InboundServiceClient("WSHttpBinding_IInboundService"))
            {
                return client.ExecutePalletizing(receiptID, pubParasInfo);
            }
        }

        public AdjustmentInfo GetAdjustmentInfoByID(string adjustmentID)
        {
            PubParasInfo pubParasInfo = this.InitPubParasInfo();
            using (InboundServiceClient client = new InboundServiceClient("WSHttpBinding_IInboundService"))
            {
                return client.GetAdjustmentInfoByID(adjustmentID, pubParasInfo);
            }
        }

        public DataSet GetAdjustmentInfoByQueryEntity(AdjustmentQueryEntity adjustmentQuery)
        {
            PubParasInfo pubParasInfo = this.InitPubParasInfo();
            using (InboundServiceClient client = new InboundServiceClient("WSHttpBinding_IInboundService"))
            {
                return client.GetAdjustmentInfoByQueryEntity(adjustmentQuery, pubParasInfo);
            }
        }

        public DataSet GetAllReceiptInfo()
        {
            PubParasInfo pubParasInfo = this.InitPubParasInfo();
            using (InboundServiceClient client = new InboundServiceClient("WSHttpBinding_IInboundService"))
            {
                return client.GetAllReceiptInfo(pubParasInfo);
            }
        }

        public static InboundServiceClientProxy GetInstance()
        {
            return new InboundServiceClientProxy();
        }

        public ReceiptInfo GetReceiptInfoByID(string receiptID, ReceiptDetailQueryEntity receiptDetailQueryEntity)
        {
            PubParasInfo pubParasInfo = this.InitPubParasInfo();
            using (InboundServiceClient client = new InboundServiceClient("WSHttpBinding_IInboundService"))
            {
                return client.GetReceiptInfoByID(receiptID, receiptDetailQueryEntity, pubParasInfo);
            }
        }

        public ReceiptInfo GetReceiptInfoByID4Exec(string receiptID)
        {
            PubParasInfo pubParasInfo = this.InitPubParasInfo();
            using (InboundServiceClient client = new InboundServiceClient("WSHttpBinding_IInboundService"))
            {
                return client.GetReceiptInfoByID4Exec(receiptID, pubParasInfo);
            }
        }

        public DataSet GetReceiptInfoByQueryEntity(ReceiptQueryEntity receiptQuery)
        {
            PubParasInfo pubParasInfo = this.InitPubParasInfo();
            using (InboundServiceClient client = new InboundServiceClient("WSHttpBinding_IInboundService"))
            {
                return client.GetReceiptInfoByQueryEntity(receiptQuery, pubParasInfo);
            }
        }

        public ReceiptInfo ImporFormSo(string soID, List<string> lineID, string receiptID, string receiptLineID, string receiptType)
        {
            PubParasInfo pubParasInfo = this.InitPubParasInfo();
            using (InboundServiceClient client = new InboundServiceClient("WSHttpBinding_IInboundService"))
            {
                return client.ImporFormSo(soID, lineID, receiptID, receiptLineID, receiptType, pubParasInfo);
            }
        }

        private PubParasInfo InitPubParasInfo()
        {
            if (base.UserInfo != null)
            {
                return new PubParasInfo { UserID = base.UserInfo.UserID, UserLanguage = base.UserInfo.Preference.Lang, CurrentWH = base.UserInfo.CurrentWH };
            }
            HttpContext.Current.Response.Redirect("../Login.aspx?from=Logout", true);
            return null;
        }

        public string InportFromPO(string poID, string receiptID, string type, string createBy)
        {
            PubParasInfo pubParasInfo = this.InitPubParasInfo();
            using (InboundServiceClient client = new InboundServiceClient("WSHttpBinding_IInboundService"))
            {
                return client.ImportFormPo(poID, receiptID, type, createBy, pubParasInfo);
            }
        }

        public string InsertReceiptInfo(ReceiptInfo receiptInfo)
        {
            PubParasInfo pubParasInfo = this.InitPubParasInfo();
            using (InboundServiceClient client = new InboundServiceClient("WSHttpBinding_IInboundService"))
            {
                return client.InsertReceiptInfo(receiptInfo, pubParasInfo);
            }
        }

        public string ReceiptRevert(AdjustmentInfo adjustmentInfo)
        {
            PubParasInfo pubParasInfo = this.InitPubParasInfo();
            using (InboundServiceClient client = new InboundServiceClient("WSHttpBinding_IInboundService"))
            {
                return client.ReceiptRevert(adjustmentInfo, pubParasInfo);
            }
        }

        public string UpdateReceiptInfo(ReceiptInfo receiptInfo)
        {
            PubParasInfo pubParasInfo = this.InitPubParasInfo();
            using (InboundServiceClient client = new InboundServiceClient("WSHttpBinding_IInboundService"))
            {
                return client.UpdateReceiptInfo(receiptInfo, pubParasInfo);
            }
        }
    }
}

